home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SAMPLES.BIN / Sound.java < prev    next >
Encoding:
Java Source  |  1996-12-03  |  5.3 KB  |  201 lines

  1. /*
  2.     A basic extension of the java.awt.Frame class
  3.  */
  4.  
  5. import java.awt.*;
  6. import symantec.itools.multimedia.SoundPlayer;
  7.  
  8. public class Sound extends Frame {
  9.     void Stop_Action(Event event) {
  10.  
  11.  
  12.         //{{CONNECTION
  13.         // Stop the sound player
  14.         {
  15.             soundPlayer1.stop();
  16.         }
  17.         //}}
  18.     }
  19.  
  20.     void radioButton2_Action(Event event) {
  21.  
  22.  
  23.     //{{CONNECTION
  24.         // Add the URL of the sound file to the play list...
  25.         {
  26.             try {
  27.             soundPlayer1.addURL(symantec.itools.net.RelativeURL.getURL("sounds/T2.au"));
  28.         } catch (java.net.MalformedURLException error){
  29.         }
  30.         }
  31.         //}}
  32.     }
  33.  
  34.     void Play_Action(Event event) {
  35.  
  36.  
  37.         //{{CONNECTION
  38.         // Start the sound player
  39.         {
  40.             soundPlayer1.play();
  41.         }
  42.         //}}
  43.     }
  44.  
  45.     void radioButton1_Action(Event event) {
  46.  
  47.  
  48.         //{{CONNECTION
  49.         // Add the URL of the sound file to the play list...
  50.         {
  51.             try {
  52.             soundPlayer1.addURL(symantec.itools.net.RelativeURL.getURL("sounds/T1.au"));
  53.         } catch (java.net.MalformedURLException error){
  54.         }
  55.         }
  56.         //}}
  57.     }
  58.  
  59.     void Close_Clicked(Event event) {
  60.  
  61.  
  62.         //{{CONNECTION
  63.         // Hide the Frame
  64.         hide();
  65.         //}}
  66.     }
  67.  
  68.  
  69.     public Sound() {
  70.  
  71.         //{{INIT_CONTROLS
  72.         setLayout(null);
  73.         addNotify();
  74.         resize(insets().left + insets().right + 411,insets().top + insets().bottom + 198);
  75.         setBackground(new Color(12632256));
  76.         imageViewer2 = new symantec.itools.multimedia.ImageViewer();
  77.         imageViewer2.reshape(insets().left + 1,insets().top + 0,104,124);
  78.         add(imageViewer2);
  79.         try {
  80.             imageViewer2.setURL(symantec.itools.net.RelativeURL.getURL("images/left.gif"));
  81.         } catch (java.net.MalformedURLException error) {
  82.         }
  83.         imageViewer1 = new symantec.itools.multimedia.ImageViewer();
  84.         imageViewer1.reshape(insets().left + 306,insets().top + -1,104,113);
  85.         add(imageViewer1);
  86.         try {
  87.             imageViewer1.setURL(symantec.itools.net.RelativeURL.getURL("images/right.gif"));
  88.         } catch (java.net.MalformedURLException error) {
  89.         }
  90.         Stop = new symantec.itools.awt.ImageButton();
  91.         Stop.reshape(insets().left + 104,insets().top + -1,101,72);
  92.         add(Stop);
  93.         Stop.setBevelHeight(1);
  94.         Stop.setNotifyWhilePressed(false);
  95.         Stop.setNotifyDelay(1000);
  96.         Stop.setShowFocus(true);
  97.         try {
  98.             Stop.setImageURL(symantec.itools.net.RelativeURL.getURL("images/stop.gif"));
  99.         } catch (java.net.MalformedURLException error) {
  100.         }
  101.         Stop.setScaleMode(false);
  102.         Stop.setCenterMode(true);
  103.         Play = new symantec.itools.awt.ImageButton();
  104.         Play.reshape(insets().left + 205,insets().top + -1,101,72);
  105.         add(Play);
  106.         Play.setBevelHeight(1);
  107.         Play.setNotifyWhilePressed(false);
  108.         Play.setNotifyDelay(1000);
  109.         Play.setShowFocus(true);
  110.         try {
  111.             Play.setImageURL(symantec.itools.net.RelativeURL.getURL("images/play.gif"));
  112.         } catch (java.net.MalformedURLException error) {
  113.         }
  114.         Play.setScaleMode(false);
  115.         Play.setCenterMode(true);
  116.         Close = new java.awt.Button("Close");
  117.         Close.reshape(insets().left + 156,insets().top + 154,97,29);
  118.         add(Close);
  119.         soundPlayer1 = new symantec.itools.multimedia.SoundPlayer();
  120.         soundPlayer1.setSyncMode(true);
  121.         soundPlayer1.setRepeat(1);
  122.         //$$ soundPlayer1.move(120,144);
  123.         radioButtonGroupPanel1 = new symantec.itools.awt.RadioButtonGroupPanel();
  124.         radioButtonGroupPanel1.setLayout(null);
  125.         radioButtonGroupPanel1.reshape(insets().left + 113,insets().top + 73,232,40);
  126.         radioButtonGroupPanel1.setBackground(new Color(12632256));
  127.         add(radioButtonGroupPanel1);
  128.         Group1 = new CheckboxGroup();
  129.         radioButton1 = new java.awt.Checkbox("Play this sound", Group1, false);
  130.         radioButton1.reshape(24,1,198,40);
  131.         radioButtonGroupPanel1.add(radioButton1);
  132.         radioButtonGroupPanel2 = new symantec.itools.awt.RadioButtonGroupPanel();
  133.         radioButtonGroupPanel2.setLayout(null);
  134.         radioButtonGroupPanel2.reshape(insets().left + 106,insets().top + 117,302,45);
  135.         add(radioButtonGroupPanel2);
  136.         radioButton2 = new java.awt.Checkbox("Play this sound too", Group1, false);
  137.         radioButton2.reshape(32,-11,190,40);
  138.         radioButtonGroupPanel2.add(radioButton2);
  139.         setTitle("Untitled");
  140.         //}}
  141.  
  142.         //{{INIT_MENUS
  143.         //}}
  144.     }
  145.  
  146.     public Sound(String title) {
  147.         this();
  148.         setTitle(title);
  149.     }
  150.  
  151.     public synchronized void show() {
  152.         move(50, 50);
  153.         super.show();
  154.     }
  155.  
  156.     public boolean handleEvent(Event event) {
  157.         if (event.id == Event.WINDOW_DESTROY) {
  158.             hide();         // hide the Frame
  159.             return true;
  160.         }
  161.         if (event.target == Close && event.id == Event.ACTION_EVENT) {
  162.             Close_Clicked(event);
  163.             return true;
  164.         }
  165.         if (event.target == radioButton1 && event.id == Event.ACTION_EVENT) {
  166.             radioButton1_Action(event);
  167.             return true;
  168.         }
  169.         if (event.target == Play && event.id == Event.ACTION_EVENT) {
  170.             Play_Action(event);
  171.             return true;
  172.         }
  173.         if (event.target == radioButton2 && event.id == Event.ACTION_EVENT) {
  174.             radioButton2_Action(event);
  175.             return true;
  176.         }
  177.         if (event.target == Stop && event.id == Event.ACTION_EVENT) {
  178.             Stop_Action(event);
  179.             return true;
  180.         }
  181.         return super.handleEvent(event);
  182.     }
  183.  
  184.     //{{DECLARE_CONTROLS
  185.     symantec.itools.multimedia.ImageViewer imageViewer2;
  186.     symantec.itools.multimedia.ImageViewer imageViewer1;
  187.     symantec.itools.awt.ImageButton Stop;
  188.     symantec.itools.awt.ImageButton Play;
  189.     java.awt.Button Close;
  190.     symantec.itools.multimedia.SoundPlayer soundPlayer1;
  191.     symantec.itools.awt.RadioButtonGroupPanel radioButtonGroupPanel1;
  192.     java.awt.Checkbox radioButton1;
  193.     CheckboxGroup Group1;
  194.     symantec.itools.awt.RadioButtonGroupPanel radioButtonGroupPanel2;
  195.     java.awt.Checkbox radioButton2;
  196.     //}}
  197.  
  198.     //{{DECLARE_MENUS
  199.     //}}
  200. }
  201.